<?php
global $user;

class Solution_model extends Model{
    
    var $id = "";
    var $username = "";
    var $password = "";
    var $fullname = "";
    var $birthday = "";
    var $address="";
    var $email="";
    var $phone="";
    var $sex ="";
    var $createDate ="";
    var $accountType=""; 
    
    function __construct(){
        parent::Model();
        $this->load->helper('url');
    }
    
    function get_accounts()
    {
        $query = $this->db->get('entries');
        return $query->result();
    }
    
    
    function createAccount(){
        $this->id = 0;
        $this->username = $this->input->post('username');
        $this->password = md5($this->input->post('password'));
        $this->fullname = $this->input->post('fullname');
        $this->birthday = $this->input->post('birthday');
        $this->address = $this->input->post('address');
        $this->email = $this->input->post('email');
        $this->phone = $this->input->post('phone');
        $this->sex = $this->input->post('sex');
        $this->accountType = $this->input->post('accountType');
        $this->createdDate = time();
        
        $this->db->insert('accounts',$this);         
    }
        
    function updateAccount(){
//        $this->id = 0;
        $this->id = $this->input->post('id');
        $this->username = $this->input->post('username');
        $this->password = md5($this->input->post('password'));
        $this->fullname = $this->input->post('fullname');
        $this->birthday = $this->input->post('birthday');
        $this->address = $this->input->post('address');
        $this->email = $this->input->post('email');
        $this->phone = $this->input->post('phone');
        $this->sex = $this->input->post('sex');
        $this->accountType = $this->input->post('accountType');
        $this->createdDate = time();
        
        $this->db->update('accounts', $this, array('id' => $_POST['id']));         
    }
    
    
} 

?>